package com.bing.springboot.controller;

import com.bing.springboot.bean.Car;
import com.bing.springboot.bean.Monster;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author 徐
 * @version 1.0
 * 处理json数据
 */
@Controller
public class ResponseController {

    /**
     * 返回Monster数据,以json格式返回
     * @return
     */
    @GetMapping("/get/monster")
    @ResponseBody
    public Monster getMonster(){

        //开发中monster从DB中获取
        Monster monster = new Monster();
        monster.setId(100);
        monster.setName("马修");
        monster.setAge(28);
        monster.setIsMarried(false);
        monster.setBirth(new Date());
        Car car = new Car();
        car.setName("宝马");
        car.setPrice(50000.0);
        monster.setCar(car);

        return monster;
    }
}
